Skip to content

fix(sdk): preserve self-mention p tags in message and forum event builders - #4975

Open
BradGroux wants to merge 2 commits into
block:mainfrom
BradGroux:fix/cli-self-mention-p-tag
Open

fix(sdk): preserve self-mention p tags in message and forum event builders#4975
BradGroux wants to merge 2 commits into
block:mainfrom
BradGroux:fix/cli-self-mention-p-tag

Conversation

@BradGroux

@BradGroux BradGroux commented Aug 5, 2026

Copy link
Copy Markdown

What users saw

buzz messages send silently removed an explicitly supplied self-mention. The caller passed --mention <sender-pubkey> and received accepted:true, but the signed event had no matching p tag and mention_pubkeys was empty.

Why it happened

nostr 0.44 strips p tags matching the signer's pubkey by default. The codebase already opts out with .allow_self_tagging() for identity archive and unarchive requests, but the message and forum builders that accept mentions did not. The library therefore removed the tag during signing after the CLI had validated the explicit mention.

What changed

Added .allow_self_tagging() to all three event builders that accept mention tags:

  • build_message (kind 9)
  • build_forum_post (kind 45001)
  • build_forum_comment (kind 45003)

An explicit mention now survives signing even when it matches the sender.

How this was tested

Added one regression test per builder. Each test signs with the same key included in the mention list and asserts that the resulting event preserves the self-referential p tag.

Validation at cd0f30bca:

./bin/cargo fmt --all -- --check
cargo test -p buzz-sdk --lib
cargo test -p buzz-cli --lib
cargo clippy -p buzz-sdk -p buzz-cli --all-targets -- -D warnings

All 257 buzz-sdk tests and all 321 buzz-cli tests passed, and formatting and strict Clippy checks completed successfully.

Scope and non-goals

  • Does not change mention validation, deduplication, or channel-member checks.
  • Does not change normalize_mention_pubkeys, which is not used by the messages-send path.
  • Does not add a dropped-mentions output field because the explicit tags are now preserved.

Closes #4906.

…lders

nostr 0.44's EventBuilder strips p tags matching the signer's pubkey by
default. build_message, build_forum_post, and build_forum_comment did not
opt in via allow_self_tagging(), so an explicit --mention <sender-pubkey>
was silently removed from the signed event. The CLI returned accepted:true
with empty mention_pubkeys — a silent-success failure.

Add .allow_self_tagging() to all three builders, matching the pattern
already used by build_archive_identity_request and build_unarchive_identity_request.

Add regression tests that sign with the same key whose pubkey is in the
mentions list and assert the p tag survives.

Refs block#4906

Co-authored-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: npub17q2gdupkvswvk5kprwc7plergm4gn295uw6fe4mjyjv53ahuhtnq02jd3f <f01486f036641ccb52c11bb1e0ff2346ea89a8b4e3b49cd772249948f6fcbae6@digitalmeld.communities.buzz.xyz>
@BradGroux
BradGroux requested a review from a team as a code owner August 5, 2026 22:47
Co-authored-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
@BradGroux

Copy link
Copy Markdown
Author

Review traced the CLI send path through the SDK builders and checked nostr 0.44's signing behavior. .allow_self_tagging() only changes preservation of p tags matching the signer, and the three changed builders are the complete set that consume mention tags. No broader functional change was needed; I pushed the rustfmt cleanup as cd0f30bca.

At that head, rustfmt, all 257 buzz-sdk tests, all 321 buzz-cli tests, and strict Clippy pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz messages send silently strips an explicit self-mention p tag

1 participant